package com.qfedu.utils;

import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;

public class ConnectionUtil {
    /***
     * 创建链接对象
     * @return
     * @throws Exception
     */
    public static Connection getConnection() throws Exception{
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("localhost"); //设置主机地址
        connectionFactory.setPort(5672);//设置端口号
        connectionFactory.setVirtualHost("qfedu");//设置虚拟主机
        connectionFactory.setUsername("admin");//设置用户名
        connectionFactory.setPassword("123");
        //获得连接
        Connection connection = connectionFactory.newConnection();

        return connection;
    }

}
